

#pragma once

#include "platform.h"

#include "drivers/bus_i2c.h"
#include "drivers/io_types.h"

typedef struct busDevice_s {
    uint8_t bustype;
    union {
        struct deviceSpi_s {
            SPI_TypeDef *instance;
#if defined(USE_HAL_DRIVER)
            SPI_HandleTypeDef* handle; // cached here for efficiency
#endif
            IO_t csnPin;
        } spi;
    } busdev_u;
} busDevice_t;

#define BUSTYPE_NONE 0
#define BUSTYPE_I2C  1
#define BUSTYPE_SPI  2

#ifdef TARGET_BUS_INIT
void targetBusInit(void);
#endif

